﻿using System.Collections.Generic;
using System.IO;

namespace AnimationPackerEngine.Animation.CommandWriters
{
    internal class Forever : ICommandWriter
    {
        private List<ICommandWriter> mCommands;

        public List<ICommandWriter> Commands
        {
            get { return mCommands; }
        }

        public Forever()
        {
            mCommands = new List<ICommandWriter>();
        }

        public void Write(BinaryWriter binaryWriter, IWriterContext context)
        {
            ICommandWriter label = new Label("loop");
            label.Write(binaryWriter, context);

            foreach (ICommandWriter writer in Commands)
            {
                writer.Write(binaryWriter, context);
            }

            ICommandWriter loop = new Goto("loop");
            loop.Write(binaryWriter, context);
        }
    }
}
